Yacon.Page = function(element){
	
	this.element = element;	
	
	/* 布局参数处理 */
	this.element.width = Yacon.getWidthNumber($(window).width());
	this.element.height = window.bodyHeight;
	this.element.search = "";
	
	/* 当前页面中组件 */
	this.component = new Array();
	this.componentIdx = new Array();
	
	this.unload = [];
	
};

Yacon.Page.prototype = {
	
	/* 信息展示 */	
	show : function(){
		
		var html = this.getHtml();	
		var self = this;
		
		$(".container-fluid.content").append(html);
		
	},
	
	/* 获取Html信息 */
	getHtml: function(){
		
		if(this.element.layout){
			
			if(!Yacon.isEmpty(this.windows)){
				
				this.windowId = this.windows.elementID;		
				
				this.element.width = Yacon.getWidthNumber(this.windows.element.width+"");
				this.element.height = Yacon.getWidthNumber(this.windows.element.height+"");
				this.element.search = "#"+this.windowId;
				
			}
			
			this.view = new Yacon.LayoutView(this.element.layout);
			
			this.view.page = this;
			
			return this.view.getLayoutHtml();
		}
		
		return "";
	},
	
	/* 添加组件 */
	addComponet : function(component){		
		this.component.add(component);
		this.componentIdx.add(component.elementID);
		eval("this."+component.elementID+" = component;");
	},
	
	/* 获取组件 */
	find : function(componentID){
		var idx = this.componentIdx.indexOf(componentID);
		return this.component.get(idx);
	},
	
	loadAfter: function(){
		for(var i=0;i<this.component.length;i++){			
			Yacon.callBack(this.component[i].elementID+"_load", [this.component[i],this]);			
		}
	},
	
	/* 绑定动作 */
	addEvents: function(componentID){
		
		if(!Yacon.isEmpty(componentID)){
			var activeElement = this.find(componentID);
			activeElement.addEvents();
		}
		else{
			for(var i=0;i<this.component.length;i++){
				var activeElement = this.component[i];
				activeElement.addEvents();
			}
			
		}
		
		/* 提示窗动作绑定  */
		addPopover();
		
		/* 添加提示框 */
		addTooltip();
		
	},
	
	/* 布局 */
	layout: function(){	
		
		for(var i=0;i<this.component.length;i++){
			var activeElement = this.component[i];
			activeElement.layoutBefore();
		}
		
		var layout = new Yacon.Layout();		
		this.layoutInner(this.element.height,this.element.search);
		this.layoutOuter(this.element.search);	
		
		this.loadAfter();
		
	},
	
	/* 外部布局 */
	layoutInner: function(height,parent){
		var layout = new Yacon.Layout();
		layout.layoutInner(height,parent);
	},
	
	/* 内部布局 */
	layoutOuter: function(parent){
		var layout = new Yacon.Layout();
		layout.layout(parent);
	},
	
	unloadEvent:function(){
		
	}
		
};